<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title><?=$da['title']?></title>
	<link rel="stylesheet" type="text/css" href="mode/weui/weui.min.css"/>
	<link rel="stylesheet" type="text/css" href="web/res/fontawesome/css/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="webmain/css/rui.css">
	<script type="text/javascript" src="js/base64-min.js"></script>

	<script type="text/javascript" src="webmain/we/ying/dist/jquery.min.js"></script>
	<script type="text/javascript" src="webmain/we/ying/ying.js"></script>

	<script type="text/javascript" src="webmain/we/ying/dist/dropload.js"></script>
	<script type="text/javascript" src="webmain/we/ying/dist/dropload.min.js"></script>
	<link rel="stylesheet" href="webmain/we/ying/dist/dropload.css">
<style>

.weui_tab{position:fixed;bottom:0px;width:100%;height:50px}
.weui_navbar_item{font-size:16px;}
.weui_navbar_item span{position:absolute;left:3px;top:3px}
.weui_navbar_item:active{background-color:#f5f5f5}


 body,html{
	 height: 100%;
	 background-color:#f1f1f1;
 }

	ul li{
		width:90%; margin-left: 5%; margin-bottom: 20px; border-radius: 5px; display: flex;flex-direction:column; background-color: white;
	}

	li span{margin: 5px 10px;}

</style>

<script>

	var json = <?=json_encode($arr)?>;

	var json1 = <?=json_encode($dataArr)?>;

	var json2 = <?=json_encode($xxdataArr)?>;

	var json3 = <?=json_encode($lowidArr)?>;

	var json4 = <?=json_encode($lowArr)?>;


	var xxarr =[];


	for (var i = 0; i< json2.length;i++ ){

		var obj = json2[i];
		xxarr.push(obj.dt)
	}


	var weeks = ["星期一","星期二","星期三","星期四","星期五","星期六","星期日"]

	var d = new Date;

	var day=d.getDate()

	var month=d.getMonth() + 1

	var year=d.getFullYear()

	var timecurrent = year + "-" + month + "-" + day;

	var sincetime = "2017-08-01";

	var tmp = timecurrent.split("-");

	var T1 = new Date(tmp[0],tmp[1]-1,tmp[2]);

	tmp = sincetime.split("-");

	var T2 = new Date(tmp[0],tmp[1]-1,tmp[2]);

	var sincedays = days(T1,T2);


	function days(t1,t2) {

		return (t1.getTime() - t2.getTime())/60/60/24/1000
	}

	var dropload;

	var refresh = 0;

	var page =0;


	var ulhtml = '';


	function load(){

		dropload = $('.element').dropload({

			scrollArea : window,

			loadDownFn : function(me){

				$.ajax({

					type: 'POST',
					url: "http://oa.wxlion.com/index.php?d=we&m=ying&a=default1&num=kqdkjl",
					// url: "http://localhost/oa/public_html/?d=we&m=ying&a=default1&num=kqdkjl",

					data: {

						page:++page
					},
					datatype: "json",
					success: function(result) {


						var arr = eval(result);

						json1 = arr;

						mykaoqin();

						me.resetload();    // 每次数据加载完，必须重置

						if(!json1.length && page*10 > sincedays){

							dropload.lock('down');
							me.noData();
							me.resetload();

						}

					},
					//调用出错执行的函数
					error: function(error1) {


					}
				});

			}

		});
	}


	function mykaoqin() {


		var kqarr = [];

		for (var i = 0;i<json1.length; i++){

			var obj = json1[i];
			var str = obj.max;
			var s = str.substring(0,10);
			kqarr.push(s);
		}

		for (var i = 10*page-10; i < 10*page; i++) {

			if(i > sincedays){break;}

			var d = new Date;

			d.setDate(d.getDate() - i);

			var day=d.getDate()

			var month=d.getMonth() + 1

			var year=d.getFullYear()

			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}

			if (day >= 1 && day <= 9) {
				day = "0" + day;
			}

			var time = year + "-" + month + "-" + day;

			var dateArray = time.split("-");
			var  date1 = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
			var currentWeek = "星期" + "日一二三四五六".charAt(date1.getDay());



			if(!array_contain(xxarr,time)){

				if (array_contain(kqarr,time)){

					for (var m = 0; m < kqarr.length;m++){

						 var s = json1[m];

						if (kqarr[m] == time && s.max != s.min){

							//上下班都打卡
							ulhtml +='<li> <div style="display: flex;width: 100%; flex-direction: row; justify-content: space-between;background-color: rgb(27,205,138) ; border-radius: 5px 5px 0px 0px;"><span>'+ time +'</span><span>'+ currentWeek +'</span></div><span>签到 '+ s.min.substr(11,8) + '&nbsp&nbsp&nbsp' + s.label + ' </span><span>签退 '+ s.max.substr(11,8) + '&nbsp&nbsp&nbsp' + s.label + '</span> </li>';

						}
						else if(kqarr[m] == time && s.max == s.min){

							//打卡一次
							ulhtml +='<li> <div style="display: flex;width: 100%; flex-direction: row; justify-content: space-between;background-color: rgb(27,205,138) ; border-radius: 5px 5px 0px 0px;"><span>'+ time +'</span><span>'+ currentWeek +'</span></div><span>签到 '+ s.min.substr(11,8) + '&nbsp&nbsp&nbsp' + s.label + ' </span><span style="display: flex-direction:row;;">签退  &nbsp&nbsp&nbsp 未打卡 </span> </li>';
						}
					}
				}

				else {
					//打卡0次
					ulhtml +='<li> <div style="display: flex;width: 100%; flex-direction: row; justify-content: space-between;background-color: rgb(27,205,138) ; border-radius: 5px 5px 0px 0px;"><span>'+ time +'</span><span>'+ currentWeek +'</span></div><span>签到 &nbsp&nbsp&nbsp 未打卡 </span><span style="display: flex-direction:row;;">签退  &nbsp&nbsp&nbsp 未打卡 </span> </li>';

				}

			}

		}

		$("#kqul").html(ulhtml);

	}


    window.onload=function(){

		if(!json3.length){

			$("#footerdiv").hide();
		}
    	load();
    	$("#kqul").html(ulhtml);
	}

    function golowerkaoqin(){

		var url='index.php?a=lowerkq&m=ying&d=we&num=kqdkjl&show=we';

		location.href=url;
	}


	function contain(s,time) {

		 for (var i=0; i<json4.length;i++){

			 var obj = json4[i];
			 if(obj.date == time && obj.uid == s.id){

				 return obj;
			 }
		 }

		 return false;

	}


	function array_contain(array, obj){
		for (var i = 0; i < array.length; i++){
			if (array[i] == obj)//如果要求数据类型也一致，这里可使用恒等号===
				return true;
		}
		return false;
	}

	function _getfirstnum(d){
		var dbh = 'def',bh='';
		var a = d[0];
		if(a){
			bh = a.url;
			if(a.submenu[0])bh=a.submenu[0].url;
		}
		if(isempt(bh))bh=dbh;
		return bh;
	}

	function yingyonginit(){
		var url = location.href;
		var urla= url.split('#'),dkey = _getfirstnum(json.menu);
		if(urla[1])dkey = urla[1];
		yy.getdata(dkey,1);
	}
	function initbody(){
		adminid = js.getoption('adminid', <?=$da['adminid']?>);
		admintoken = js.getoption('admintoken', '<?=$xhrock->admintoken?>');
		yy.init();
		yingyonginit();
	}
</script>
</head>






<div class="element" style="width: 100%;  margin-top: 10px; overflow: auto;">

	<ul id="kqul">


	</ul>

</div>




<div id="footerdiv" style="height:50px;overflow:hidden">
<div  style="z-index:5" class="weui_tab">
	<div class="weui_navbar weui_tabbar">

		<div class="weui_navbar_item" onclick="golowerkaoqin()">下属考勤</div>
	</div>
</div>
</div>


<?php
if($yyurljs!='')echo '<script type="text/javascript" src="'.$yyurljs.'"></script>'."\n";
?>
<script type="text/javascript" src="web/res/js/jquery-imgview.js"></script>
<script type="text/javascript" src="web/res/js/jquery-rockupload.js"></script>
<script type="text/javascript" src="web/res/js/jquery-changeuser.js"></script>
</>
</html>